<template>
  <view class="box">
    <view
      class="tou topNoBg"
      :style="'padding-top:' + statusBarHeight1 + 'px'"
      style="background: transparent"
    >
      <!-- <view class="toptitle">个人信息</view>
      <image class="back" src="https://pic.bangbangtongcheng.com/static/fanhui_bai.png" @click="back" />-->
      <image
        @click="back"
        class="image1"
        src="https://pic.bangbangtongcheng.com/static/seting-fanhui.png"
      />
      <span style="font-weight: 700; font-size: 32rpx; color: #000000">账号管理</span>
    </view>
    <view class="topNoBg" :style="'padding-top:' + statusBarHeight1 + 'px'"></view>
    <view class="content" :style="'height:calc( 100vh - ' + statusBarHeight1 + 'px - 88rpx)'">
      <view class="flex">
        <view>账 号 设 置 ：</view>
        <view>{{ userInfo.phone }}</view>
        <image
          class="right"
          src="https://pic.bangbangtongcheng.com/static/zhanghao-bianji.png"
          mode="widthFix"
          @click="modify(2)"
        />
      </view>
      <view class="gapLine"></view>
      <!-- 			<view class="flex">
				<view>修 改 头 像 ：</view>
				<view class="userHeaderBox">
					<image class="userHeader" :src="userInfo.image" />
					<view class="secondaryContent" style="font-size: 24rpx;">合适头像增加印象</view>
					<view class="edit">
						<image src="https://pic.bangbangtongcheng.com/static/zhanghao-bianji-white.png" mode="widthFix"
							@click="ChooseImage1" />
					</view>
				</view>
			</view> -->
      <!-- 			<view class="flex">
				<view>修 改 昵 称 ：</view>
				<view>{{ userInfo.nikeName }}</view>
				<image class="right" src="https://pic.bangbangtongcheng.com/static/zhanghao-bianji.png" mode="widthFix"
					@click="modify(1)" />
			</view> -->

      <view class="flex">
        <view>设 置 密 码 ：</view>
        <view class="flexConterView">{{ viewPasswordText }}</view>
        <image
          class="right"
          @click="viewPassword"
          style="right: 120rpx; width: 35rpx; display: none"
          src="https://pic.bangbangtongcheng.com/static/zhanghao-biyan.png"
          mode="widthFix"
        />
        <image
          class="right"
          src="https://pic.bangbangtongcheng.com/static/zhanghao-bianji.png"
          mode="widthFix"
          @click="modify(3)"
        />
      </view>
      <view class="gapLine"></view>

      <!-- #ifdef APP-PLUS -->
      <view class="touxiang">
        <view class="touxiang_left bottomBorder">
          绑 定 微 信：
          <!-- <image class="image" src="https://pic.bangbangtongcheng.com/static/bindWX.png" mode=""></image> -->
          <view class="secondaryContent">绑定微信登录更便捷</view>
        </view>
        <switch @change="SwitchA" :checked="switchA" />
      </view>
      <view class="gapLine"></view>
      <!-- TODO: 暂时隐藏支付宝登录（支付宝图标不展示，同上） -->
      <view class="touxiang">
				<view class="touxiang_left bottomBorder">
					绑定支付宝：
					<!-- <image class="image" src="/static/Alipay.png" mode=""></image> -->
					<view class="secondaryContent ">绑定支付宝登录更便捷</view>
				</view>
				<switch @change="SwitchB" :checked="switchB" />
			</view>
      <view class="gapLine"></view>
      <!-- #endif -->
    </view>
    <!-- #ifdef MP-WEIXIN -->
    <cropper ref="croop" v-show="showCroop" :quality="1" resize: false :canScale="true"
    selWidth="660rpx" selHeight="660rpx" @upload="myUpload" class="userHeader" />
    <!-- #endif -->
    <!-- #ifndef MP-WEIXIN-->
    <gmy-img-cropper
      ref="gmyImgCropper"
      quality="1"
      cropperType="fixed"
      fileType="jpg"
      imgSrc=""
      @getImg="myUpload"
    >
    </gmy-img-cropper>
    <!-- #endif -->
    <!-- #ifdef APP-PLUS -->
    <unlock
      ref="creatureUnlock"
      v-if="creatureUnlock"
      @cancel="cancel"
      @fail="fail"
      @bonanza="bonanza"
    />
    <!-- #endif -->
    <uni-popup ref="unbundleWx" mode="center">
      <view class="window">
        <view class="window_top">
          <view class="window_text">解除与微信账号的绑定?</view>
        </view>
        <view class="window_btn_box">
          <view class="window_btn" @click="cannerBindWx">取消</view>
          <view class="window_btn window_btn1" @click="bindWeChat('', 0)">解除绑定</view>
        </view>
      </view>
    </uni-popup>
    <uni-popup ref="binds1" mode="center">
      <view class="window">
        <view class="window_top">
          <view class="window_text">解除与支付宝账号的绑定?</view>
        </view>
        <view class="window_btn_box">
          <view class="window_btn" @click="cannerBindAli">取消</view>
          <view class="window_btn window_btn1" @click="bindAlipay('', 0)">解除绑定</view>
        </view>
      </view>
    </uni-popup>
    <uniBall></uniBall>
    <view class="switchAccounts" @click="switchAccounts" v-if="userInfo.phone">切换账号</view>
    <view class="logout" @click="logout" v-if="userInfo.phone">退出登录</view>
    <uni-popup ref="binds" mode="center">
      <view class="binds_frame">
        <view class="binds_frame_t">提示</view>
        <view class="binds_frame_c">是否确认退出？</view>
        <view class="binds_frame_b">
          <view class="cancel" @click="jcbdCancel">取消</view>
          <view class="determine" @click="confirmReceipt">确定</view>
        </view>
      </view>
    </uni-popup>
  </view>
</template>

<script>
  import permision from '@/js_sdk/wa-permission/permission.js'
  // #ifdef APP-PLUS
  import unlock from '@/components/unlock/Creature-Unlock.vue'
  // #endif
  //#ifdef H5
  import wxshare from '../utils/index.js'
  //#endif
  import { mapGetters } from 'vuex'
  //#ifdef MP-WEIXIN
  import cropper from '../components/lxiaoxiao-cropper/lxiaoxiao-cropper.vue'
  //#endif

  // #ifndef MP-WEIXIN
  import gmyImgCropper from '../components/gmy-img-cropper/gmy-img-cropper.vue'
  //#endif

  // import cropper from "../../uni_modules/buuug7-img-cropper/pages/cropper"
  export default {
    components: {
      // #ifndef MP-WEIXIN
      gmyImgCropper,
      //#endif
      //#ifdef MP-WEIXIN
      cropper,
      //#endif
      //#ifdef APP-PLUS
      unlock: unlock,
      //#endif
    },
    data() {
      return {
        viewPasswordText: '******',
        imgUrl: this.$imgSrc,
        confirm: false,
        userInfo: {},
        phone: '',
        merchantMessage: {},
        modal_qr: false,
        urls: '',
        switchA: false,
        fingerprintChage: false,
        creatureUnlock: false,
        // 小程序裁剪是否展示
        showCroop: false,
        switchB: false,
		platform:'',
        convencid: uni.getStorageSync('convencid') ? uni.getStorageSync('convencid') : '',
      }
    },
    computed: {
      ...mapGetters(['statusBarHeight1', 'userinfo']),
    },
    onShow() {
      this.userInfo = uni.getStorageSync('Pduser') 
      this.phone = uni.getStorageSync('Pduser').phone
      //this.phone = this.userInfo.phone;
      console.log('this.phone', this.phone)
      if (this.phone) {
        this.getUserPhone()
      } else {
		  clearTimeout(time)
		  uni.showToast({
		    title: '未登录',
		    icon: 'none',
		    duration: 1000,
		  })
		  var time = setTimeout(() => {
		    this.$TOLOGIN('isLogout=1');
		    clearTimeout(time)
		  }, 1000)
	  }
      // if (this.userInfo.isShop == 1) {
      // 	this.getShopInfo()
      // }
      this.urls = `https://www.bangbangtongcheng.com/conven_web/#/pages_my/setInfo?userId=${this.userInfo.id}`
      // this.showQrcode(); //一加载生成二维码
      this.queryBindWeChat()
      // this.queryBindAlipay()
    },

    onLoad(options) {
      if (getApp().globalData.confirm) {
        this.confirm = getApp().globalData.confirm
      }
      /* #ifdef H5 */
      this.jinzhi()
      /* #endif */
	  // 先判断 系统版本
	  uni.getSystemInfo({
	    success: (res) => {
	      this.system = res.system.substring(4, 6)
	      this.platform = res.platform
	    },
	    fail: (err) => {},
	    complete: () => {},
	  })
      if (this.userInfo == '') {
        clearTimeout(time)
        uni.showToast({
          title: '未登录',
          icon: 'none',
          duration: 1000,
        })
        var time = setTimeout(() => {
          this.$TOLOGIN('isLogout=1');
          clearTimeout(time)
        }, 1000)
      }
      // this.queryBindWeChat()
      let zwjs_key = uni.getStorageSync('zwjs_key')
      if (zwjs_key) {
        this.fingerprintChage = true
      }
    },
    methods: {
      jcbdCancel() {
        this.$refs.binds.close()
      },
      confirmReceipt() {
        let that = this
        uni.removeStorageSync('Pduser')
        uni.removeStorageSync('userInfo')
        uni.removeStorageSync('sessionKey')
        uni.removeStorageSync('curriculumVitae')
        that.$store.dispatch('user/logout', {})
        // uni.navigateBack();
        this.jcbdCancel();
        // 用户提出 退出登录不需要返回账号管理页
        this.$TOLOGIN('isLogout=1');
        // this.$TOLOGIN('isLogout=1&isNeedBack=true');
      },
      logout() {
        let that = this
        that.$refs.binds.open()
        //    uni.showModal({
        //      title: "提示",
        //      content: "是否确认退出？",
        //      success: function (res) {
        //        console.log(res, '点击退出登录');
        //        if (res.confirm) {
        //          console.log(res, '确认退出');
        //          // uni.removeStorage({
        //          //   key: "Pduser"
        //          // });
        //          uni.removeStorageSync("Pduser");
        //          uni.removeStorageSync("userInfo");
        // uni.removeStorageSync("sessionKey");
        //          const user = uni.getStorageSync('Pduser')
        //          console.log(user, '111111111');
        //          that.$store.dispatch("user/logout", {});
        //          uni.navigateBack();
        //        } else if (res.cancel) {}
        //      }
        //    });
        // this.$store.dispatch("user/logout", {});
        // uni.navigateBack();
      },
      switchAccounts() {
        uni.navigateTo({
          url: '/pages_my/switchAccount',
        })
      },
      // 查看密码
      viewPassword() {
        const pwd = '******'
        if (this.viewPasswordText === pwd) {
          this.viewPasswordText = this.userInfo.password
        } else {
          this.viewPasswordText = pwd
        }
      },
	  unbundleWxClose() {
	    this.$refs.unbundleWx.close()
	  },
	  cannerBindWx() {
	    this.$refs.unbundleWx.close()
		this.switchA = true
	  },
	  cannerBindAli() {
	    this.$refs.binds1.close()
	  	this.switchB = true
	  },
      bindsClose1() {
        this.$refs.binds1.close()
      },
      SwitchA(e) {
        this.switchA = e.target.value
        if (this.switchA) {
          uni.login({
            provider: 'weixin',
            success: (res) => {
              this.getApploginData(res)
            },
            fail: (error) => {
              console.log('失败')
              this.queryBindWeChat()
            },
          })
        } else {
          this.$refs.unbundleWx.open()
        }
      },
      SwitchB(e) {
        this.switchB = e.target.value
        if (this.switchB) {
          this.alipayLogin()
        } else {
          this.$refs.binds1.open()
        }
      },
      // 获取unionid
      getApploginData(data) {
        var that = this
        //这边是前端自己去调微信用户信息的接口，根据接口需要请求，如果不需要前端去获取的话就交给后端，可省去次操作
        uni.request({
          url:
            'https://api.weixin.qq.com/sns/userinfo?access_token=' +
            data.authResult.access_token +
            '&openid=' +
            data.authResult.openid,
          method: 'GET',
          dataType: 'json',
          header: {
            'content-type': 'application/x-www-form-urlencoded', // 默认值
          },
          success(res) {
            let data = res.data
            that.bindWeChat(data.unionid, 1)
          },
          fail: (err) => {
            this.queryBindWeChat()
          },
        })
      },
      // 绑定vx/解绑vx
      bindWeChat(id, index) {
        this.unbundleWxClose()
        this.$myRequest
          .post('/api/mobile/public/bindingOrUnbindWeChat', {
            userId: this.userInfo.id,
            bindingState: index,
            openId: id || '',
          })
          .then((res) => {
            uni.showToast({
              title: res.msg,
              icon: 'none',
              mask: true,
            })
            setTimeout(() => {
              this.queryBindWeChat()
            }, 500)
          })
      },
      // 判断用户是否绑定微信
      queryBindWeChat() {
        this.$myRequest
          .get('/api/mobile/public/whetherBindWeChatLogin', {
            userId: this.userInfo.id,
          })
          .then((res) => {
            if (res.existBindWeChatLogin == 1) {
              this.switchA = true
            } else {
              this.switchA = false
            }
          })
      },
      // 绑定vx/解绑vx
      bindAlipay(id, index) {
        this.bindsClose1()
        console.log({
          userId: this.userInfo.id,
          bindingState: index,
          openId: id || '',
        })
        this.$myRequest
          .post('/api/mobile/public/bindingOrUnbindAli', {
            userId: this.userInfo.id,
            bindingState: index,
            openId: id || '',
          })
          .then((res) => {
            uni.showToast({
              title: res.msg,
              icon: 'none',
              mask: true,
            })
            setTimeout(() => {
              this.getUserPhone()
            }, 500)
          })
          .catch((err) => {
            setTimeout(() => {
              this.getUserPhone()
            }, 500)
          })
      },
      // 判断用户是否绑定微信
      queryBindAlipay() {
        this.$myRequest
          .get('/api/mobile/public/whetherBindWeChatLogin', {
            userId: this.userInfo.id,
          })
          .then((res) => {
            if (res.existBindWeChatLogin == 1) {
              this.switchB = true
            } else {
              this.switchB = false
            }
          })
      },
      // 支付宝登录
      alipayLogin() {
        let that = this
        const plug = uni.requireNativePlugin('Html5app-AlipayAuth')
        if (that.platform == 'ios' || that.platform == 'IOS') {
          plug.login(
            {
              appid: '2021003144632733',
              urlscheme: 'convenAlilogin',
            },
            (ret) => {
              if (ret.code == 0) {
                console.log(ret.result.auth_code, '-------')
                let auth_code = ret.result.auth_code
                that.$myRequest
                  .get('/mob/login/aliLogin', {
                    code: auth_code,
                    convencid: that.convencid,
                  })
                  .then((res) => {
                    console.log(res)
                    if (res.userInfo.phone) {
                      uni.showLoading({
                        title: '登录中...',
                      })
                    }
                    this.bindAlipay(res.userInfo.zfbOpenid, 1)
                  })
              }
            }
          )
        } else {
          plug.login(
            {
              appid: '2021003144632733',
            },
            (ret) => {
              if (ret.code == 0) {
                console.log(ret.result.auth_code, '-------')
                let auth_code = ret.result.auth_code
                that.$myRequest
                  .get('/mob/login/aliLogin', {
                    code: auth_code,
                    convencid: that.convencid,
                  })
                  .then((res) => {
                    console.log(res)
                    if (res.userInfo.phone) {
                      uni.showLoading({
                        title: '登录中...',
                      })
                    }
                    this.bindAlipay(res.userInfo.zfbOpenid, 1)
                  })
              } else {
                uni.showToast({
                  title: '授权失败',
                  icon: 'none',
                  mask: true,
                })
              }
            }
          )
        }
      },
      fingerprintSwitch(e) {
        this.fingerprintChage = e.target.value
        if (this.fingerprintChage) {
          this.creatureUnlock = true
        } else {
          uni.removeStorageSync('zwjs_key')
          uni.showToast({
            title: '指纹解锁已关闭！',
            icon: 'none',
            mask: true,
          })
        }
      },
      bonanza() {
        this.creatureUnlock = false
        uni.setStorageSync('zwjs_key', true)
        uni.showToast({
          title: '指纹解锁开启成功！',
          icon: 'none',
          mask: true,
        })
      },
      fail() {
        this.creatureUnlock = false
        this.fingerprintChage = false
      },
      cancel() {
        this.creatureUnlock = false
        this.fingerprintChage = false
      },
      // 展示二维码
      showQrcode() {
        let _this = this
        this.modal_qr = true
        // uni.showLoading()
        setTimeout(function () {
          // uni.hideLoading()
          _this.$refs.uqrcode.crtQrCode()
        }, 50)
      },

      goRz() {
        if (
          this.userInfo.businessType == 0 &&
          this.userInfo.enterpriseRecruitmentStatus == 0 &&
          this.userInfo.personalRecruitmentStatus == 0
        ) {
          uni.redirectTo({
            url: '/pages_recruitMoney/my/certificationInformation',
          })
          return
        }
        uni.navigateTo({
          url: './rengzheng',
        })
      },

      //传入组件的方法
      hideQrcode() {
        this.modal_qr = false
      },

      getShopInfo() {
        this.$myRequest
          .get('/mob/user/getShopInfoDetailByCopy', {
            id: this.userInfo.shopId,
          })
          .then((res) => {
            this.merchantMessage = res.shopInfo
          })
      },
      amend() {
        uni.navigateTo({
          url: '/pages_my/enter_merchant?amend=1',
        })
      },
      //离职功能
      dimission() {
        let _this = this
        if (this.userInfo.isAgent == 0) {
          uni.showToast({
            title: '您还不是经纪人',
            icon: 'error',
            duration: 2000,
          })
          return
        } else {
          if (this.userInfo.isShop == 1) {
            uni.showToast({
              title: '商家不能主动离职,仅能注销',
              icon: 'none',
              duration: 2000,
            })
            return
          }
          uni.showModal({
            title: '警告',
            content: '确定要主动离职吗？',
            success: (res) => {
              if (res.confirm) {
                if (this.userInfo.businessType == 1) {
                  this.$myRequest
                    .post('mob/user/autoconfirmResignation', {
                      userId: this.userInfo.id,
                    })
                    .then((res) => {
                      console.log(res)
                      uni.showToast({
                        title: res.msg,
                        icon: 'none',
                      })
                      setTimeout(() => {
                        _this.getUserPhone()
                      }, 1000)
                    })
                } else {
                  this.$myRequest
                    .post('/api/mobile/vehicleOwner/voluntaryResignation', {
                      userId: this.userInfo.id,
                    })
                    .then((res) => {
                      console.log(res)
                      uni.showToast({
                        title: res.msg,
                        icon: 'none',
                      })
                      setTimeout(() => {
                        _this.getUserPhone()
                      }, 1000)
                    })
                }
              } else if (res.cancel) {
                console.log('用户点击取消')
              }
            },
          })
        }
      },
      back() {
        uni.navigateBack({
          delta: 1,
        })
      },
      modify(type) {
        uni.navigateTo({
          url: '/pages_my/modify?type=' + type,
        })
      },
      jinzhi() {
        let _this = this
        let param = window.location.href.split('#')[0]
        uni.request({
          method: 'post',
          data: {
            url: param,
          },
          header: {
            'content-type': 'application/x-www-form-urlencoded',
          },
          url: 'https://www.bangbangtongcheng.com/conven//mob/login/getJsTicket.do',
          success(re) {
            _this.jinzhifx(re.data)
          },
        })
      },
      jinzhifx(data) {
        wxshare.config({
          debug: false, //是否打开调试
          appId: data.appId, // 公众号的唯一标识
          timestamp: data.timestamp, // 生成签名的时间戳
          nonceStr: data.nonce, // ，生成签名的随机串
          signature: data.signature, // 签名
          jsApiList: ['hideMenuItems'],
        })
        // 禁止分享
        wxshare.hideMenuItems({
          // 要隐藏的菜单项，只能隐藏“传播类”和“保护类”按钮，所有menu项见附录3
          menuList: [
            'menuItem:share:appMessage',
            'menuItem:share:timeline',
            'menuItem:share:timeline',
            'menuItem:share:qq',
            'menuItem:favorite',
            'menuItem:share:QZone',
            'menuItem:openWithSafari',
          ],
        })
      },
      async ChooseImage1() {
        // #ifdef APP-PLUS
        this.$refs.gmyImgCropper.chooseImage()
        //  #endif
        // #ifdef MP-WEIXIN
        this.showCroop = true
        this.$refs.croop.fSelect()
        //  #endif
        // #ifdef H5
        this.$refs.gmyImgCropper.chooseImage()
        // #endif
      },
      myUpload(rsp) {
        console.log(rsp, 11111111111)
        let filePath = ''
        // #ifndef MP-WEIXIN
        this.userInfo.image = rsp
        filePath = rsp
        // #endif
        // #ifdef MP-WEIXIN
        this.userInfo.image = rsp.path
        filePath = rsp.path
        this.showCroop = false
        //  #endif

        uni.showToast({
          title: '正在上传请稍后',
          icon: 'none',
          duration: 2000,
        })
        var _this = this
        uni.uploadFile({
          // 需要上传的地址
          url: 'https://www.bangbangtongcheng.com/conven/ht/attach/qnUpload',
          // filePath  需要上传的文件
          filePath: filePath,
          name: 'file',
          success(res1) {
            let url = JSON.parse(res1.data).data[0].url
            console.log(url)
            _this.$myRequest
              .post('/mob/user/updateUserInfo', {
                id: _this.userInfo.id,
                image: url,
              })
              .then((res) => {
                // const that = this;
                //       uni.navigateTo({
                //         events: {
                //           imgCropped(event) {
                //             // 监听裁剪完成
                //             // 返回的 event 中包含了已经裁剪好图片的base64编码字符串
                //             // 你可以使用 <image :src="imgDataUrl" mode="aspectFit"></image> 组件来展示裁剪后的图片
                //             // 或者你可以将该字符串通过接口上传给服务器用来保存
                //             console.log(event);
                //             that.userInfo.image = event.data;
                //             // do whatever you want
                //             // upload to server
                //           },
                //         },
                //       });
                uni.showToast({
                  title: res.msg,
                  icon: 'none',
                })
                setTimeout(() => {
                  _this.getUserPhone()
                }, 1000)
              })
          },
        })
      },
      ChooseImage() {
        let _this = this
        uni.chooseImage({
          count: 1,
          sizeType: ['copressed'],
          sourceType: ['camera', 'album'],
          crop: {
            width: 500,
            height: 500,
            // quality: 80
            // resize: false
          },
          success(res) {
            //因为有一张图片， 输出下标[0]， 直接输出地址
            const tempFiles = res.tempFiles
            let length = ''
            // #ifdef H5
            length = tempFiles[0].name.length
            let resType = tempFiles[0].name.substring(length - 1, length)
            // #endif
            // #ifndef H5
            length = tempFiles[0].path.length
            let resType = tempFiles[0].path.substring(length - 1, length)
            // #endif
            if (resType != 'g' && resType != 'G') {
              uni.showToast({
                title: '不支持当前文件格式',
                icon: 'none',
              })
              return
            }
            var imgFiles = res.tempFilePaths
            var uper
            imgFiles.forEach((el) => {
              uni.showToast({
                title: '正在上传请稍后',
                icon: 'none',
                duration: 2000,
              })
              uper = uni.uploadFile({
                // 需要上传的地址
                url: 'https://www.bangbangtongcheng.com/conven/ht/attach/qnUpload',
                // filePath  需要上传的文件
                filePath: el,
                name: 'file',
                success(res1) {
                  // console.log(res1.data);
                  let url = JSON.parse(res1.data).data[0].url
                  _this.$myRequest
                    .post('/mob/user/updateUserInfo', {
                      id: _this.userInfo.id,
                      image: _this.imgUrl + url,
                    })
                    .then((res) => {
                      // const that = this;
                      //       uni.navigateTo({
                      //         url: "../../uni_modules/buuug7-img-cropper/pages/cropper",
                      //         events: {
                      //           imgCropped(event) {
                      //             // 监听裁剪完成
                      //             // 返回的 event 中包含了已经裁剪好图片的base64编码字符串
                      //             // 你可以使用 <image :src="imgDataUrl" mode="aspectFit"></image> 组件来展示裁剪后的图片
                      //             // 或者你可以将该字符串通过接口上传给服务器用来保存
                      //             console.log(event);
                      //             that.userInfo.image = event.data;
                      //             // do whatever you want
                      //             // upload to server
                      //           },
                      //         },
                      //       });
                      uni.showToast({
                        title: res.msg,
                        icon: 'none',
                      })
                      setTimeout(() => {
                        _this.getUserPhone()
                      }, 1000)
                    })
                },
              })
            })

            // onProgressUpdate 上传对象更新的方法
            uper.onProgressUpdate(function (res) {})
          },
          fail: (fail) => {
            // uni.showModal({
            //   title: '提示',
            //   content: '操作权限已被拒绝，请手动前往设置',
            //   confirmText: '立即设置',
            //   success: (res) => {
            //     if (res.confirm) {
            //       if (plus.os.name === 'iOS') {
            //         plus.runtime.openURL('app-settings://')
            //       } else {
            //         var Intent = plus.android.importClass('android.content.Intent')
            //         var Settings = plus.android.importClass('android.provider.Settings')
            //         var Uri = plus.android.importClass('android.net.Uri')
            //         var mainActivity = plus.android.runtimeMainActivity()
            //         var intent = new Intent()
            //         intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
            //         var uri = Uri.fromParts('package', mainActivity.getPackageName(), null)
            //         intent.setData(uri)
            //         mainActivity.startActivity(intent)
            //       }
            //     }
            //   },
            // })
          },
        })
      },
      getUserPhone() {
        let that = this
        this.$myRequest
          .get('/mob/login/getUserInfoByPhone', {
            phone: this.phone,
          })
          .then((res) => {
            this.userInfo = res.userInfo
            uni.setStorageSync('Pduser', res.userInfo)
            that.$store.dispatch('user/login', res.userInfo)
            if (this.userInfo.zfbOpenid) {
              this.switchB = true
            } else {
              this.switchB = false
            }
            console.log(this.userinfo)
          })
      },

      // 去个人信息扫码页面
      goSetInfo() {
        uni.navigateTo({
          url: './setInfo',
        })
      },
    },
  }
</script>

<style scoped lang="less">
  page {
    background-color: #fff;
  }

  .gapLine {
    background: #ebebed;
    height: 1rpx;
    margin-right: 50rpx;
    margin-left: 235rpx;
  }

  .box {
    background-image: url(https://pic.bangbangtongcheng.com/static/bbcz/accountManager.png);
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
  }

  .touxiang {
    width: 100%;
    height: 100rpx;
    //border-bottom: 2rpx solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 30rpx 48rpx 30rpx 30rpx;

    .touxiang_left {
      display: flex;
      align-items: center;
      font-size: 34rpx;

      .image {
        width: 45rpx;
        height: 45rpx;
        margin-left: 20rpx;
      }
    }

    .secondaryContent {
      font-weight: 400;
      font-size: 28rpx;
      color: #cccccc;
    }

    .huancun {
      display: flex;
      align-items: center;
    }

    .img2 {
      width: 18rpx;
      height: 35rpx;
    }

    /deep/uni-switch .uni-switch-input.uni-switch-input-checked {
      background-color: #0fa291 !important;
    }

    /deep/ uni-switch::after,
    uni-switch::before {
      content: '';
    }

    /deep/uni-switch .wx-switch-input,
    /deep/uni-switch .uni-switch-input {
      width: 80rpx;
      height: 40rpx;
      background-color: #8799a3 !important;
    }

    /deep/uni-switch .wx-switch-input::after,
    /deep/uni-switch .uni-switch-input::after {
      width: 45rpx;
      height: 40rpx;
    }
  }

  .content {
    /* #ifdef MP */
    /* height: calc(100vh - 192rpx); */
    /* #endif */
    /* #ifdef APP-PLUS || H5 */
    /* height: calc(100vh - statusBarHeight1 - 88rpx); */
    /* var(--status-bar-height1) */
    /* #endif */
    .title {
      margin-top: 34rpx;
      font-size: 34rpx;
      color: #64b6a8;
      margin-bottom: 34rpx;
    }

    .merchanTxt {
      font-size: 30rpx;
      margin-bottom: 12rpx;

      .merchan {
        color: #64b6a8;
      }
    }

    .merchanImg {
      margin-bottom: 40rpx;

      .merchanImgTxt {
        font-size: 34rpx;
        margin-bottom: 22rpx;
      }

      .imgs {
        width: 690rpx;
        height: 228rpx;
      }
    }
  }

  .flex {
    display: flex;
    align-items: center;
    /* justify-content: space-between; */
    justify-content: start;
    padding: 30rpx 106rpx 30rpx 30rpx;
    /* border-bottom: 2rpx solid #e0e0e0; */
    font-size: 34rpx;
    position: relative;

    .flexConterView {
      width: 360rpx;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 1; //想要的行数
      word-break: break-all;
      -webkit-box-orient: vertical;
    }

    .right {
      position: absolute;
      top: 50%;
      right: 49rpx;
      transform: translateY(-50%);
      width: 28rpx;
      height: 28rpx;
    }

    .secondaryContent {
      color: #cccccc;
      font-size: 28rpx;
    }
  }

  .userHeaderBox {
    position: relative;

    .userHeader {
      width: 150rpx;
      height: 150rpx;
      border-radius: 50%;
    }

    text-align: center;
    padding-left: 70rpx;

    .edit {
      position: absolute;
      bottom: 40rpx;
      right: 20rpx;
      width: 50rpx;
      height: 50rpx;
      line-height: 50rpx;
      text-align: center;
      background: #0fa291;
      border-radius: 50%;

      image {
        width: 22rpx;
        height: 22rpx;
      }
    }
  }

  .image1 {
    position: absolute;
    width: 32rpx;
    height: 32rpx;

    left: 30rpx;
  }

  .tou {
    position: fixed;
    width: 100%;
    text-align: left;
    line-height: 88rpx;
    font-size: 32rpx;
    color: black;
    z-index: 10;

    span {
      padding-left: 70rpx;
    }
  }

  .certifi-data {
    padding: 0 0 34rpx 0rpx;

    .certifi-top {
      display: flex;
      align-items: center;
      padding: 30rpx;
      border-bottom: 2rpx solid #e0e0e0;

      text {
        margin-right: 48rpx;
        font-size: 34rpx;
        font-weight: 400;
        color: #333333;
      }

      view {
        display: flex;
        align-items: center;
        font-size: 34rpx;
        color: #64b6a8;
      }
    }

    .certifi-content {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;

      view {
        font-size: 28rpx;
        font-weight: 600;
        color: #64b6a8;
        margin: 60rpx 0 0rpx;
      }

      image {
        width: 270rpx;
        height: 270rpx;
      }
    }
  }

  .qr-codes {
    /* margin-left: -40rpx;
		 padding: ;*/
    /* #ifdef MP-WEIXIN */
    padding-right: 80rpx;
    /* #endif */
  }

  .window {
    width: 600rpx;
    background: #fff;
    border-radius: 10rpx;
    padding: 54rpx 0 0;
    position: relative;
    overflow: hidden;

    .window_text {
      margin-bottom: 60rpx;
      font-size: 34rpx;
      line-height: 48rpx;
      color: #333;
      text-align: center;
    }

    .text_widnow {
      padding: 16rpx;
      min-height: 160rpx;
      background: #f2f2f2;
      border-radius: 10rpx;
      opacity: 1;
      font-size: 24rpx;
      line-height: 34rpx;
      margin-bottom: 20rpx;
    }

    .show {
      text-align: right;
      font-size: 24rpx;
      color: #64b6a8;
      line-height: 34rpx;
      padding-bottom: 20rpx;
    }

    .window_btn_box {
      display: flex;
      justify-content: center;

      .window_btn {
        width: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        height: 90rpx;
        background: #f2f2f2;
        font-size: 30rpx;
      }

      .window_btn1 {
        color: #fff;
        background: #64b6a8;
      }
    }
  }

  .switchAccounts {
    width: 670rpx;
    height: 90rpx;
    line-height: 90rpx;
    text-align: center;
    color: #fff;
    font-size: 30rpx;
    border-radius: 45rpx;
    margin: 0 auto;
    position: fixed;
    bottom: 160rpx;
    left: 50%;
    transform: translateX(-50%);
    background: #0fa291;
  }

  .logout {
    position: fixed;
    bottom: 80rpx;
    left: 50%;
    transform: translateX(-50%);
    font-weight: 400;
    font-size: 32rpx;
    color: #999999;
  }

  .binds_frame {
    width: 600rpx;
    background-color: #ffffff;
    // padding-bottom: 50rpx;
    border-radius: 20rpx;
    text-align: center;
    font-size: 36rpx;
    overflow: hidden;

    .binds_frame_t {
      font-weight: 550;
      color: #000000;
      padding: 0 46rpx;
      padding-top: 36rpx;
    }

    .binds_frame_c {
      width: 500rpx;
      margin: 0 auto;
      font-weight: 500;
      color: #000000;
      margin-top: 30rpx;
      margin-bottom: 50rpx;
    }

    .binds_frame_b {
      display: flex;
      align-items: center;
      justify-content: space-between;

      .cancel {
        flex: 1;
        height: 90rpx;
        border: 1px solid #eee;
        border-radius: 10rpx 0 0 10rpx;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 400;
        color: #999999;
      }

      .determine {
        flex: 1;
        height: 90rpx;
        border: 1px solid #eee;
        border-radius: 0 10rpx 10rpx 0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 400;
        color: #0fa291;
      }
    }
  }
</style>
